//设置cookie
function setCookie(key, value, expires) {
    if (expires) {
        var time = new Date();
        time.setTime(time.getTime() - 8 * 60 * 60 * 1000 + 1000 * expires);
        document.cookie = key + "=" + value + ";expires=" + time;
    } else {
        document.cookie = key + "=" + value;
    }
}
//获取cookie
function getCookie(key) {
    str = "";
    var tmp = document.cookie.split('; ');

    for (var i = 0; i < tmp.length; i++) {
        var t = tmp[i].split('=');
        if (t[0] === key) {
            str = t[1];
        }
    }
    return str;
}